package com.example.medical.service.impl;


import com.example.medical.domain.Equipment;
import com.example.medical.mapper.EquipmentMapper;
import com.example.medical.service.EquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EquipmentServiceImpl implements EquipmentService {

    @Autowired
    EquipmentMapper mapper;

    // 获取所有设备信息列表
    @Override
    public List<Equipment> selectAll() {
        return mapper.selectAll();
    }

    // 根据设备id获取对应的设备信息
    @Override
    public Equipment selectById(int id) {
        return mapper.selectById(id);
    }

    @Override
    public int saveEquipment(Equipment equipment) {

        return mapper.saveEquipment(equipment);
    }
    // 更新器械信息，调用Mapper层方法根据传入的器械对象更新数据库中对应记录，并返回更新影响的行数
    @Override
    public int updateEquipment(Equipment equipment) {
        return mapper.updateEquipmentById(equipment);
    }

    // 删除器械，调用Mapper层方法根据传入的器械id删除数据库中对应记录，并返回删除影响的行数
    @Override
    public int deleteEquipment(int id) {
        return mapper.deleteEquipmentById(id);
    }


    @Override
    public String checkEquipment(Equipment equipment) {
        int res = mapper.checkEquipment(equipment);
        if (res == 1) {
            return "设备登录成功";
        } else {
            return "设备账号或密码错误";
        }
    }
}